home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / demo / client / scripts / missionDownload.cs < prev    next >
Encoding:
Text File  |  2006-09-21  |  4.7 KB  |  158 lines

  1. //-----------------------------------------------------------------------------
  2. // Torque Game Engine 
  3. // Copyright (C) GarageGames.com, Inc.
  4. //-----------------------------------------------------------------------------
  5.  
  6. //----------------------------------------------------------------------------
  7. // Mission Loading & Mission Info
  8. // The mission loading server handshaking is handled by the
  9. // common/client/missingLoading.cs.  This portion handles the interface
  10. // with the game GUI.
  11. //----------------------------------------------------------------------------
  12.  
  13. //----------------------------------------------------------------------------
  14. // Loading Phases:
  15. // Phase 1: Download Datablocks
  16. // Phase 2: Download Ghost Objects
  17. // Phase 3: Scene Lighting
  18.  
  19. //----------------------------------------------------------------------------
  20. // Phase 1
  21. //----------------------------------------------------------------------------
  22.  
  23. function onMissionDownloadPhase1(%missionName, %musicTrack)
  24. {
  25.    // Close and clear the message hud (in case it's open)
  26.    MessageHud.close();
  27.    //cls();
  28.  
  29.    // Reset the loading progress controls:
  30.    LoadingProgress.setValue(0);
  31.    LoadingProgressTxt.setValue("LOADING DATABLOCKS");
  32. }
  33.  
  34. function onPhase1Progress(%progress)
  35. {
  36.    LoadingProgress.setValue(%progress);
  37.    Canvas.repaint();
  38. }
  39.  
  40. function onPhase1Complete()
  41. {
  42. }
  43.  
  44. //----------------------------------------------------------------------------
  45. // Phase 2
  46. //----------------------------------------------------------------------------
  47.  
  48. function onMissionDownloadPhase2()
  49. {
  50.    // Reset the loading progress controls:
  51.    LoadingProgress.setValue(0);
  52.    LoadingProgressTxt.setValue("LOADING OBJECTS");
  53.    Canvas.repaint();
  54. }
  55.  
  56. function onPhase2Progress(%progress)
  57. {
  58.    LoadingProgress.setValue(%progress);
  59.    Canvas.repaint();
  60. }
  61.  
  62. function onPhase2Complete()
  63. {
  64. }   
  65.  
  66. function onFileChunkReceived(%fileName, %ofs, %size)
  67. {
  68.    LoadingProgress.setValue(%ofs / %size);
  69.    LoadingProgressTxt.setValue("Downloading " @ %fileName @ "...");
  70. }
  71.  
  72. //----------------------------------------------------------------------------
  73. // Phase 3
  74. //----------------------------------------------------------------------------
  75.  
  76. function onMissionDownloadPhase3()
  77. {
  78.    LoadingProgress.setValue(0);
  79.    LoadingProgressTxt.setValue("LIGHTING MISSION");
  80.    Canvas.repaint();
  81. }
  82.  
  83. function onPhase3Progress(%progress)
  84. {
  85.    LoadingProgress.setValue(%progress);
  86. }
  87.  
  88. function onPhase3Complete()
  89. {
  90.    LoadingProgress.setValue( 1 );
  91.    $lightingMission = false;
  92. }
  93.  
  94. //----------------------------------------------------------------------------
  95. // Mission loading done!
  96. //----------------------------------------------------------------------------
  97.  
  98. function onMissionDownloadComplete()
  99. {
  100.    // Client will shortly be dropped into the game, so this is
  101.    // good place for any last minute gui cleanup.
  102. }
  103.  
  104.  
  105. //------------------------------------------------------------------------------
  106. // Before downloading a mission, the server transmits the mission
  107. // information through these messages.
  108. //------------------------------------------------------------------------------
  109.  
  110. addMessageCallback( 'MsgLoadInfo', handleLoadInfoMessage );
  111. addMessageCallback( 'MsgLoadDescripition', handleLoadDescriptionMessage );
  112. addMessageCallback( 'MsgLoadInfoDone', handleLoadInfoDoneMessage );
  113.  
  114. //------------------------------------------------------------------------------
  115.  
  116. function handleLoadInfoMessage( %msgType, %msgString, %mapName ) {
  117.     
  118.     // Need to pop up the loading gui to display this stuff.
  119.    if (!LoadingGui.isAwake())
  120.        Canvas.setContent("LoadingGui");
  121.  
  122.     // Clear all of the loading info lines:
  123.     for( %line = 0; %line < LoadingGui.qLineCount; %line++ )
  124.         LoadingGui.qLine[%line] = "";
  125.     LoadingGui.qLineCount = 0;
  126.  
  127.    //
  128.     LOAD_MapName.setText( %mapName );
  129. }
  130.  
  131. //------------------------------------------------------------------------------
  132.  
  133. function handleLoadDescriptionMessage( %msgType, %msgString, %line )
  134. {
  135.     LoadingGui.qLine[LoadingGui.qLineCount] = %line;
  136.     LoadingGui.qLineCount++;
  137.  
  138.    // Gather up all the previous lines, append the current one
  139.    // and stuff it into the control
  140.     %text = "<spush><font:Arial:16>";
  141.     
  142.     for( %line = 0; %line < LoadingGui.qLineCount - 1; %line++ )
  143.         %text = %text @ LoadingGui.qLine[%line] @ " ";
  144.    %text = %text @ LoadingGui.qLine[%line] @ "<spop>";
  145.  
  146.     LOAD_MapDescription.setText( %text );
  147. }
  148.  
  149. //------------------------------------------------------------------------------
  150.  
  151. function handleLoadInfoDoneMessage( %msgType, %msgString )
  152. {
  153.    // This will get called after the last description line is sent.
  154. }
  155.  
  156. function onNeedRelight() // stop console spam ***KCF*** 21-SEP-2006
  157. {
  158. }